package test;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2021-04-23
 * Time: 14:42
 */
public class Contact {
    private String name;
    private String phoneNumber;
    private boolean status;
    private RelationshipType relationship;

    public Contact(String name, String phoneNumber, RelationshipType relationship) {
        this.name = name;
        this.phoneNumber = phoneNumber;
        this.relationship = relationship;
        this.status = true;
    }

    public Contact(String name, String phoneNumber) {
        this.name = name;
        this.phoneNumber = phoneNumber;
        this.relationship = RelationshipType.FRIEND;
        this.status = true;
    }

    public String getName() {
        return name;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public boolean isActive() {
        return status;
    }

    public RelationshipType getRelationship() {
        return relationship;
    }

    public void setActive(boolean status) {
        this.status = status;
    }

    public void setRelationship(RelationshipType relationship) {
        this.relationship = relationship;
    }

    @Override
    public String toString() {
        if (status) {
            return name + " (" + phoneNumber + "), " + relationship;
        } else {
            return name + " is an inactive record.";
        }
    }
}

//    public static void main(String[] args) {
//        test.Contact c1 = new test.Contact("John", "7589943", test.RelationshipType.FAMILY);
//        c1.setActive(false);
//        System.out.println(c1);
//    }


    abstract class DivideAndConquerSort {

    void templateSort(int[] a, int n) {
            if (n < 2) {
                return;
            }
            int mid = n / 2;
            int[] l = new int[mid];
            int[] r = new int[n - mid];
            for (int i = 0; i < mid; i++) {
                l[i] = a[i];
            }
            for (int i = mid; i < n; i++) {
                r[i - mid] = a[i];
            }
            sortHalves(l, mid);
            sortHalves(r, n - mid);
            merge(a, l, r, mid, n - mid);
        }

        abstract void sortHalves(int[] a, int n);

        abstract void merge(int[] a, int[] l, int[] r, int mid, int midToend);
    }

    class MergeSortA extends DivideAndConquerSort {

        public void sortHalves(int[] a, int n) {
            System.out.print("Numbers arrived for test.MergeSortA: "); //variant code
            for (int i : a)
                System.out.print("[" + i + "]"); //may be treated as variant code
            System.out.println("\nSorting a half in test.MergeSortA by using a different step implementation"); //variant code
        }

        public void merge(int[] a, int[] l, int[] r, int mid, int midToend) {
            System.out.println("Merging the common.stack.delayStack.two halves");
        }

    }

    class MergeSortB extends DivideAndConquerSort {
        public void sortHalves(int[] a, int n) {
            System.out.print("Numbers arrived for test.MergeSortB: "); //variant code
            for (int i : a)
                System.out.print("[" + i + "]"); //may be treated as variant code
            System.out.println("\nSorting a half in test.MergeSortB by using a different step implementation"); //variant code
        }

        public void merge(int[] a, int[] l, int[] r, int mid, int midToend) {
            System.out.println("Merging the common.stack.delayStack.two halves");
        }
    }

